package com.woniu.controller;

import com.woniu.commons.Result;
import com.woniu.controller.form.OrderVo;
import com.woniu.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author Kevin Kwok
 * @create 2021-04-15 19:09
 */
@RestController
@RequestMapping("/epai/order")
@CrossOrigin
@Slf4j
public class OrderController {
    @Resource
    private IOrderService iOrderService;

    /**
     * 前端用户获取全部订单的接口
     * @return
     */
    @GetMapping("getOrders")
    @RequiresPermissions({"订单查询"})
    public Result getOrders(){

        List<OrderVo> orders = iOrderService.getAllOrders();
        log.info("全部订单：{}",orders);
        return new Result("200","success",null,orders);
    }
    /**
     * 前端用户获取未付款订单的接口
     * @return
     */
    @GetMapping("getUnpaidOrders/{status}")
    @RequiresPermissions({"订单查询"})
    public Result getUnpaidOrders(@PathVariable Integer status){

        List<OrderVo> orders = iOrderService.getOrders(status);
        log.info("待付款订单：{}",orders);

        return new Result("200","success",null,orders);
    }


}
